<?php

namespace common\models;

class LogHelper
{
    public static function Logging($filePath, $error)
    {
        self::mkdirs(dirname($filePath));
        $file = fopen($filePath, "a");
        fwrite($file, date("Y-m-d H:i:s", time()) . PHP_EOL . 'Info:' . var_export($error, true));
        fwrite($file, PHP_EOL . '================ Update End ===============' . PHP_EOL . PHP_EOL);
        fclose($file);
    }

    public static function mkdirs($catalogue)
    {
        if (!file_exists($catalogue)) {
            self::mkdirs(dirname($catalogue));
            mkdir($catalogue, 0777);
        }

        return true;
    }
}